Skip to content

Conversation

@armenzg
Copy link
Member

@armenzg armenzg commented Oct 15, 2025

Changes included:

  • Start transaction for each process
  • Add metric to track process errors

Changes included:
* Start transaction for each process
* Add metric to track process errors
@armenzg armenzg requested a review from wedamija October 15, 2025 20:57
@armenzg armenzg self-assigned this Oct 15, 2025
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Oct 15, 2025

return

model_name, chunk = j
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section is easier to review by hiding the white spaces:
https://github.com/getsentry/sentry/pull/101558/files?diff=split&w=1

logger.exception("Error in multiprocess_worker.")
finally:
task_queue.task_done()
with sentry_sdk.start_transaction(op="cleanup", name="multiprocess_worker") as transaction:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the errors from the processes are missing the transaction:

Image

finally:
task_queue.task_done()
with sentry_sdk.start_transaction(op="cleanup", name="multiprocess_worker") as transaction:
transaction.set_tag("model", model_name)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will help me distinguish the impact per model.

if not task.chunk(apply_filter=True):
break
except Exception:
metrics.incr("cleanup.error", instance=model_name)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually we can create monitors for this. We should not let things get as bad as they currently are.

is_flag=True,
help="Send the duration of this command to internal metrics.",
hidden=True,
help="(deprecated) Send the duration of this command to internal metrics.",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All scripts are passing the --timed parameter, thus, we don't need this.

# main process tracks the overall cleanup operation performance.
with sentry_sdk.start_transaction(op="cleanup", name="cleanup") as transaction:
transaction.set_tag("router", router)
transaction.set_tag("model", model)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All errors are happening within the processes, thus, these taggings are useless.
I will remove the other one on a different commit/PR to save triggering CI.

@armenzg armenzg requested a review from a team October 15, 2025 21:21
@armenzg armenzg marked this pull request as ready for review October 15, 2025 21:21
cursor[bot]

This comment was marked as outdated.

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Oct 15, 2025
@ryan953 ryan953 removed the Scope: Frontend Automatically applied to PRs that change frontend components label Oct 15, 2025
@getsentry getsentry deleted a comment from github-actions bot Oct 15, 2025
@armenzg armenzg enabled auto-merge (squash) October 16, 2025 12:25
if not task.chunk(apply_filter=True):
break
except Exception:
metrics.incr("cleanup.error", instance=model_name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want a sample_rate=1.0 on this as our default sampling rate of 10% could mean no metrics.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point.

model: tuple[str, ...],
router: str | None,
timed: bool,
_: bool,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change the name of this parameter? Click uses parameter names to pass CLI flags in.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I renamed it since it was not being used. I didn't realized of the importance of it. I can verify that it would have broken the script. Thank you.

Copy link
Member Author

@armenzg armenzg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready for another review. Thank you!

model: tuple[str, ...],
router: str | None,
timed: bool,
_: bool,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I renamed it since it was not being used. I didn't realized of the importance of it. I can verify that it would have broken the script. Thank you.

if not task.chunk(apply_filter=True):
break
except Exception:
metrics.incr("cleanup.error", instance=model_name)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point.

@armenzg armenzg merged commit 59cf5e0 into master Oct 17, 2025
69 checks passed
@armenzg armenzg deleted the 0/ref/cleanup/armenzg branch October 17, 2025 17:52
@sentry-io
Copy link

sentry-io bot commented Oct 18, 2025

Issues attributed to commits in this pull request

This pull request was merged and Sentry observed the following issues:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants